layui.config({
    base : "/dhjdglxt/modules/util/"//自定义加载的模块
}).use(['form','layer','jquery','layedit','laydate','laypage','table','commUtil','element','treetable'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;
    var table = layui.table;
    var commUtil = layui.commUtil;
    var element = layui.element;
    var treetable = layui.treetable;//很重要


    //监听工具条
    table.on('tool(modelInfo)', function(obj){
        var data = obj.data;
        if(obj.event === 'remove'){
            remove(data)
        }else if(obj.event === 'edit'){
            edit(data)
        }else if(obj.event === 'view'){
            view(data)
        }
    });


    $(".onQuery").click(function(){
        onQuery();
    })

    $(".onImport").click(function(){
        var type =$("#pageType").val();
        window.open(basePath+'/service/airplanebaseinfo/airplanebaseinfo/listNewImport/'+type);
    })


    //改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
    /*
    **新增
    */
    $(window).one("resize",function(){
        $(".onAdd").click(function(){
            var url = basePath+"/modules/jksxgl/jksxglInfo.jsp";
            var index = layui.layer.open({
                title : "新增",
                type : 2,
                skin:'layui-layer-molv',
                content : url,
                area: ['990px', '740px'],
                offset: 't',
                success : function(layero, index){
                    commUtil.resizeLayer(index,'740');
                }
            })
//			layui.layer.full(index);
        })
    }).resize();

    //查询
    function onQuery(){
        var s_gjNo = $('#s_gjNo').val();
        var s_airModel = $('#s_airModel').val();

        //执行重载
        table.reload('modelInfo', {
            page: {
                curr: 1 //重新从第 1 页开始
            },
            where: {
                s_gjNo: s_gjNo,
                s_airModel: s_airModel
            }
        });
    }

    //删除
    function remove(obj) {
        layer.confirm("你确定删除数据吗？", {icon: 3, title:'提示' ,offset: '30%'},
            function(index){//确定回调
                $.ajax({
                    type: "DELETE",
                    url:basePath+'/service/jksxgl/jddtjksxgl/'+obj.recId,
                    async:false,
                    dataType: "json",
                    success: function(data){
                        location.reload();
                    }
                });
                layer.close(index);
            },function (index) {//取消回调
                layer.close(index);
            }
        );
    }
    //编辑
    function edit(obj) {
        var index = layui.layer.open({
            title : "编辑",
            type : 2,
            skin:'layui-layer-molv',
            content : basePath+"/service/jksxgl/jddtjksxgl/"+obj.recId+"?eric=edit",
            area: ['990px', '600px'],
            offset: 't',
            success : function(layero, index){
                commUtil.resizeLayer(index,'600');
            }
        })
    }
    //查看
    function view(obj) {
        var index = layui.layer.open({
            title : "查看",
            type : 2,
            skin:'layui-layer-molv',
            content : basePath+"/service/jksxgl/jddtjksxgl/"+obj.recId+"?eric=view",
            area: ['990px', '600px'],
            offset: 't',
            success : function(layero, index){
                commUtil.resizeLayer(index,'600');
            }
        })
    }
})
function HTMLDecode(text) {
    var temp = document.createElement("div");
    temp.innerHTML = text;
    var output = temp.innerText || temp.textContent;
    temp = null;
    return output;
}
